package com.weixing.mall.provider.config;

import com.google.code.kaptcha.impl.DefaultKaptcha;
import com.google.code.kaptcha.util.Config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.Properties;

/**
 * Description:google 验证码工具配置类  <br/>
 *
 * @param:
 * @return:
 * @Author: kfc
 * @Date: 2018/10/26 15:45
 */
@Configuration
public class KaptchaConfig {

    @Bean
    public DefaultKaptcha producer() {
        Properties properties = new Properties();
        properties.put("kaptcha.border", "no");
        properties.put("kaptcha.textproducer.font.color", "black");
        properties.put("kaptcha.textproducer.char.space", "10");
        properties.put("kaptcha.textproducer.char.length","4");
        properties.setProperty("kaptcha.image.width", "125");
        properties.put("kaptcha.image.height","38");
        properties.put("kaptcha.textproducer.font.size","25");

//        properties.put("kaptcha.noise.impl","com.google.status.kaptcha.impl.NoNoise");
        properties.put("kaptcha.noise.impl","com.google.code.kaptcha.impl.NoNoise");
        properties.setProperty("kaptcha.obscurificator.impl","com.weixing.mall.provider.config.NoWaterRipple");
        Config config = new Config(properties);
        DefaultKaptcha defaultKaptcha = new DefaultKaptcha();
        defaultKaptcha.setConfig(config);
        return defaultKaptcha;
    }
}
